package cn.golxen.rsms.commons.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.messaging.MessagingException;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
import java.util.Random;

public class MailUtils {


    public static SimpleMailMessage setEmailMessage(String to,String code){
        try {
            SimpleMailMessage mailMessage = new SimpleMailMessage();
            //主题
            mailMessage.setSubject("验证码邮件");
            //生成随机数
//            String code = CommonsUtils.randomCode();
            //内容
            mailMessage.setText("欢迎使用Golxen门店管理系统，您收到的验证码是：" + code);
            //发给谁
            mailMessage.setTo(to);
            //自己的邮箱
            mailMessage.setFrom("153578456@qq.com");

            return mailMessage;
            //发送
//            javaMailSender.send(mailMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }




}

